The present disclosure relates in general to receiving and processing page fault exceptions in supervisory software when accessing data structures. More specifically, the present disclosure relates to systems and methodologies that limit the protection violations that can occur when attempting to access strings that span across a memory boundary.
Null-terminated strings are often used in C and other programming languages. A null-terminated string is a contiguous sequence of characters (or elements, or bytes), wherein the last character in the string is a null character (typically a “0” value) that indicates the end of the string. Because an application does not know the actual size or location of a C-style null-terminated string, the application typically accesses, reads and loads null-terminated strings by sequentially accessing, reading and loading individual string characters until a null character is reached.
Memory may be organized into blocks. The address locations in a single block or page of memory typically share a common set of address translations and access permissions. Because the address locations in page memory are often some form of virtual memory address, address translations are needed in order to convert the virtual memory address to a physical or real memory address. Access permissions determine whether an application has privileges to read or write the contents of a memory page. A null-terminated string may be located at any arbitrary address within a memory page, including for example, near the end of a page, spanning a boundary that separates two different pages, or extending up to the end of a page without crossing the page boundary. An application attempting to access a null-terminated string that spans a page boundary must have access permissions for both pages. If the application has access to the first page but not the second page, a page fault violation occurs when the application attempts to perform an address translation for the second page. In order to protect system integrity, operating systems are typically strict in not allowing applications to access to a page without having the proper access permission. Thus, operating systems typically kill the offending application in response to a page access violation.
Single instruction multiple data (SIMD) processing is a performance enhancement feature that allows one instruction to operate on multiple data items at the same time. Thus, SIMD allows what usually requires a repeated succession of instructions (e.g., a loop) to be performed in one instruction. For a number of string data functions such as a comparison of two different strings or a string copy operation, SIMD has the potential to reduce processing time by processing multiple string characters in parallel. However, much of this reduced processing time is offset by the additional software overhead that is needed in order to avoid the above-described page translation violations that would occur if an application attempts a parallel data access and load (e.g., an SIMD load) of data that cross a memory page boundary, wherein the application does not have access privileges to the pages on both sides of the boundary.